﻿using AntdUI;
using Super.Admin.Global;
using Super.Admin.Utils.ThemeManager;
using Super.Admin.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Super.Admin.Utils.EventAggregator.EventType;
using Super.Admin.Utils.EventAggregator;

namespace Super.Admin.Views.Main
{
    public partial class UcMainDrawerSetting : UserControl
    {
        public UcMainDrawerSettingAppearanceSetting UcMainDrawerSettingAppearanceSetting { get; private set; }
        public UcMainDrawerSettingGeneralSetting UcMainDrawerSettingGeneralSetting { get; private set; }
        public UcMainDrawerSettingLayoutSetting UcMainDrawerSettingLayoutSetting { get; private set; }
        public UcMainDrawerSettingShortcutSetting UcMainDrawerSettingShortcutSetting { get; private set; }

        public UcMainDrawerSetting()
        {
            InitializeComponent();
            InitializeControls();
            this.Load += UcMainDrawerSetting_Load;
        }

        private void UcMainDrawerSetting_Load(object? sender, EventArgs e)
        {
            // 设置选项为外观
            BtnSettingsOption.SelectIndex = 0;
        }

        private void InitializeControls()
        {
            UcMainDrawerSettingAppearanceSetting = new UcMainDrawerSettingAppearanceSetting();
            UcMainDrawerSettingGeneralSetting = new UcMainDrawerSettingGeneralSetting();
            UcMainDrawerSettingLayoutSetting = new UcMainDrawerSettingLayoutSetting();
            UcMainDrawerSettingShortcutSetting = new UcMainDrawerSettingShortcutSetting();
            UcMainDrawerSettingGeneralSetting.Dock = DockStyle.Fill;
            UcMainDrawerSettingAppearanceSetting.Dock = DockStyle.Fill;
            UcMainDrawerSettingLayoutSetting.Dock = DockStyle.Fill;
            UcMainDrawerSettingShortcutSetting.Dock = DockStyle.Fill;
            PnlSettingMain.Controls.Add(UcMainDrawerSettingAppearanceSetting);
        }

        private void BtnSettingsOption_SelectIndexChanged(object sender, IntEventArgs e)
        {
            PnlSettingMain.Controls.Clear();
            if (BtnSettingsOption.SelectIndex == 0)
            {
                PnlSettingMain.Controls.Add(UcMainDrawerSettingAppearanceSetting);
            }
            else if (BtnSettingsOption.SelectIndex == 1)
            {
                PnlSettingMain.Controls.Add(UcMainDrawerSettingLayoutSetting);
            }
            else if (BtnSettingsOption.SelectIndex == 2)
            {
                PnlSettingMain.Controls.Add(UcMainDrawerSettingShortcutSetting);
            }
            else if (BtnSettingsOption.SelectIndex == 3)
            {
                PnlSettingMain.Controls.Add(UcMainDrawerSettingGeneralSetting);
            }
        }

        private void BtnClose_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void BtnResetPreferenceSettings_Click(object sender, EventArgs e)
        {
            EventAggregator.Default.Publish<AppearanceSettingEvent>(new AppearanceSettingEvent { Type = AppearanceSettingEvent.AppearanceSettingType.ResetPreferenceSettings, Value = true });
        }

        private void BtnCopyPreferenceSettings_Click(object sender, EventArgs e)
        {
            EventAggregator.Default.Publish<AppearanceSettingEvent>(new AppearanceSettingEvent { Type = AppearanceSettingEvent.AppearanceSettingType.CopyPreferenceSettings, Value = true });
        }

        private void BtnLogout_Click(object sender, EventArgs e)
        {
            EventAggregator.Default.Publish<AppearanceSettingEvent>(new AppearanceSettingEvent { Type = AppearanceSettingEvent.AppearanceSettingType.ClearCacheAndLogout, Value = true });
        }
    }
}
